In test cases, use gmtime
to avoid timezone & daylight savings issues
#12508
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is just a fix to a few test cases; it does not make any changes to the pip source code.
I'm in Sydney, Australia, and just started looking at the pip code for the first time.
First thing I do is clone and run the test via
nox
. I found test cases failing because of a difference in time stamps found on log messages. Looking further, I see that someone had already had the sense to usetime.timezone
to adjust thetimet
style timestamps into local times. However, this adjustment fails when in Sydney as the baked-in date used by the testcases (1547704837.040001 / 2019-01-17T06:00:37,040) falls within daylight savings here, and so the formatted time becomes "2019-01-17T07:00:37,040" - an hour ahead.I've had enough pain with python, timestamp and time-zones to NOT want to have to make pip a test-bed for all of python's time-zone shortcoming, so the fix in this PR is to have these test cases monkey-patch the root
logging.Formatter
to useconverter=time.gmtime
, and to remove the earliertime.timezone
adjustments. This now allows the tests cases to pass in southern hemisphere geographies that observe daylight savings.